//
//  ViewController.m
//  核心动画-CABasicAnimation
//
//  Created by hyl on 16/7/4.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *greenView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //开启动画
    CABasicAnimation *basic=[CABasicAnimation animation];
    //描述哪个属性产生动画
    basic.keyPath=@"position";
    //设置值
    basic.toValue=[NSValue valueWithCGPoint:CGPointMake(200, 450)];
    //设置动画完成时候不再移除动画
    basic.removedOnCompletion=NO;
    //设置动画执行完成要保持最新的效果
    basic.fillMode=kCAFillModeForwards;
    //添加动画
    [self.greenView.layer addAnimation:basic forKey:nil];
}
@end
